/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.ly.ocw.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ly.ocw.service.VcodeService;
/**
 * 验证码处理Controller.
 * 
 * @author peter
 */
@Controller
@RequestMapping(value = "/valiCode")
public class ValiCodeController {
	
	private static Logger logger = LoggerFactory.getLogger(ValiCodeController.class);
	
	@Autowired
	private VcodeService vcodeService;
	
	/**
	 * 发送手机验证码
	 */
	@RequestMapping(value = "sendValiCode/{mobilePhone}", method = RequestMethod.GET)
	@ResponseBody
	public String sendValiCode(@PathVariable("mobilePhone") String mobilePhone) {
		logger.info("sendValiCode ------- mobilePhone："+mobilePhone);
		
		try {
			vcodeService.sendSms(mobilePhone);
			return "true";
		} catch (Exception e) {
			logger.error("验证码发送失败 "+mobilePhone);
			return "false";
		}
		
	}

	
	
}
